package com.vince.hulk.states
{
import assets.levelStates.LevelState1Bg;

import com.vince.hulk.model.GameConst;
import com.vince.hulk.menu.PauseMenu;

import flexunit.framework.Test;

import org.flixel.FlxGroup;
import org.flixel.FlxSprite;
import org.flixel.FlxText;
import org.flixel.FlxTilemap;

/**
 * author yangwz
 */		
public class LevelState1 extends PlayState
{
	public function LevelState1()
	{
		super();
	}
	//==========================================================================
	//  Variables
	//==========================================================================
	[Embed(source = "assets/LevelState1Bg.png")]
	private var bg:Class;
	
	private var mapData:XML = <Test>
						<Objects>
							<type type="character" x="100" y="100" size="1"/>
							<type type="character" x="150" y="100" size="2"/>
							<type type="button" x="100" y="100" size="1"/>
							<type type="switch" x="120" y="100" size="1"/>
							<type type="movableblock" x="200" y="120" size="1"/>
							<type type="fan" x="100" y="200" direction="up"/>
							<type type="fan" x="0" y="200" direction="right"/>
						</Objects>
						<Tiles info="1,2,3">
							<type info="1,2,3" type="fan," x="0" y="200" direction="right"/>
							<type info="1,2,3" type="fan," x="0" y="200" direction="right"/>
							<type info="1,2,3" type="fan," x="0" y="200" direction="right"/>
							<type info="1,2,3" type="fan," x="0" y="200" direction="right"/>
							<type info="1,2,3" type="fan," x="0" y="200" direction="right"/>
							<type info="1,2,3" type="fan" x="0" y="200" direction="right"/>
							<type info="1,2,3" type="fan" x="0" y="200" direction="right"/>
						</Tiles>
					  </Test>;
	
	[Embed(source = "assets/Tiles.png")]
	private var imgTiles:Class;
	//==========================================================================
	//  Methods
	//==========================================================================
	override public function create():void
	{
		super.create();
		var level1Bg:FlxSprite = new FlxSprite(0, 0, bg);
		add(level1Bg);
		levelName.text = GameConst.LEVEL1_NAME;
		var tip1:FlxText = new FlxText(50, 300, 300, "LEFT-ARROW to move left,\nRIGHT-ARROW to move right");
		var tip2:FlxText = new FlxText(400, 300, 250, "UP-ARROW to jump");
		tip1.setFormat(null, 16);
		tip2.setFormat(null, 16);
		add(tip1);
		add(tip2);
		_map1 = new FlxTilemap();
		mechanisms = new FlxGroup(30);
		activeChar = 0;
		curChars = new Array();
		loadMap(mapData, _map1, imgTiles, 10, 10);
//		loadMap(new this.DataMap(), _map1, imgTiles, 10, 10);
		finishCharSize = 1;
		thisLevelClass = LevelState1;
		nextLevelClass = LevelState2;
		twoStarTime = 10;
		threeStarTime = 5;
		pause = new PauseMenu();
	}
}
}